package buco.jsonrpc;

import java.io.IOException;
import java.io.Writer;

import org.json.simple.*;

import buco.core.api.*;

public class ImportPackageRequirementConverter implements JSONStreamAware {

	private ImportPackageRequirement req; 
	
	public ImportPackageRequirementConverter(ImportPackageRequirement req) {
		this.req = req;  		
	}
	
	@SuppressWarnings("unchecked")
	@Override
	public void writeJSONString(Writer wr) throws IOException {	
		JSONObject reqJson = new JSONObject(); 
		reqJson.put("type", ImportPackageRequirement.class.getSimpleName());
		reqJson.put("packageName", req.getPackageName()); 
		VersionRange range = req.getPackageVersionRange(); 
		if(range != null) { 
			reqJson.put("packageVersionRange", range.toString()); 
		}
		reqJson.writeJSONString(wr);
	}

}
